/**
 * @description 商品列表
 * @author liyunfu
 */

const Product = require("../../models/Product");

!(async () => {
  //创建几个商品
//   await Product.create({
//     shopId: "61da2b298ebd89a847161ab5", //沃尔玛
//     name: "葡萄",
//     imgUrl: "/images/product/grape.jpg",
//     sales: 100, //月售
//     price: 33, //当前价格
//     oldPrice: 36, //原价
//     tabs: ["all", "seckill", "fruit"],
//   });
//   await Product.create({
//     shopId: "61da2b298ebd89a847161ab5", //沃尔玛
//     name: "苹果",
//     imgUrl: "/images/product/apple.jpeg",
//     sales: 200, //月售
//     price: 30, //当前价格
//     oldPrice: 36, //原价
//     tabs: ["all", "seckill", "fruit"],
//   });
//   await Product.create({
//     shopId: "61da2b298ebd89a847161ab8", //沃尔玛
//     name: "桃子",
//     imgUrl: "/images/product/peach.jpg",
//     sales: 50, //月售
//     price: 33, //当前价格
//     oldPrice: 40, //原价
//     tabs: ["all", "seckill", "fruit"],
//   });
//   await Product.create({
//     shopId: "61da2b298ebd89a847161ab8", //沃尔玛
//     name: "西瓜",
//     imgUrl: "/images/product/watermelon.jpg",
//     sales: 400, //月售
//     price: 10, //当前价格
//     oldPrice: 20, //原价
//     tabs: ["all", "seckill", "fruit"],
//   });
  
    //查询某个商店，某个tab的商品列表
    const list=await Product.find({
        shopId:'61da2b298ebd89a847161ab8',
        tabs:{
            $in:'seckill'  //秒杀
        }
    }).sort({_id:-1})
    console.log(list)
})();
